
/**
 ******************************************************************************
 * @file    usb_desc.c
 * @brief   Descriptors for Virtual Com Port Demo
 ******************************************************************************
 * @attention
 *
 * <h2><center>&copy; COPYRIGHT 2013 STMicroelectronics</center></h2>
 *
 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
 * You may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *        http://www.st.com/software_license_agreement_liberty_v2
 *
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 ******************************************************************************
 */

/* 包含文件 ------------------------------------------------------------------*/
#include "usb_lib.h"
#include "usb_desc.h"

/* USB 标准设备描述符 */
const uint8_t Virtual_Com_Port_DeviceDescriptor[] =
{
    0x12,                             /* bLength */
    USB_DEVICE_DESCRIPTOR_TYPE,       /* bDescriptorType */
    0x10,
    0x01,                             /* bcdUSB = 1.10 */
    0xff,                             /* bDeviceClass: CDC */
    0x00,                             /* bDeviceSubClass */
    0x00,                             /* bDeviceProtocol */
    0x40,                             /* bMaxPacketSize0 */
    0x86,
    0x1a,                             /* idVendor = 0x1A86 */
    0x23,
    0x75,                             /* idProduct = 0x7523 */
    0x64,
    0x02,                             /* bcdDevice = 2.00 */
    1,                                /* 制造商描述符的索引 */
    2,                                /* 产品描述符的索引 */
    3,                                /* 设备序列号的描述符的索引 */
    0x01                              /* 配置描述符的数量 */
};

const uint8_t Virtual_Com_Port_ConfigDescriptor[] =
{
    /* 配置描述符 */
    0x09,                             /* bLength: 配置描述符的长度 */
    USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */
    VIRTUAL_COM_PORT_SIZ_CONFIG_DESC,  /* wTotalLength: 所有返回的字节数 */
    0x00,
    0x01,                             /* bNumInterfaces: 接口的数量 */
    0x01,                             /* bConfigurationValue: 配置值 */
    0x00,                             /* iConfiguration: 描述该配置的字符串描述符的索引 */
    0x80,                             /* bmAttributes: 自供电 */
    0x30,                             /* MaxPower: 0 mA */

    /* 接口描述符 */
    0x09,                             /* bLength: 接口描述符的长度 */
    USB_INTERFACE_DESCRIPTOR_TYPE,    /* bDescriptorType: Interface */
    /* 接口描述符类型 */
    0x00,                             /* bInterfaceNumber: 接口的编号 */
    0x00,                             /* bAlternateSetting: 替代设置 */
    0x03,                             /* bNumEndpoints: 使用的端点数 */
    0xff,                             /* bInterfaceClass: 通信接口类 */
    0x01,                             /* bInterfaceSubClass: 抽象控制模型 */
    0x02,                             /* bInterfaceProtocol: 通用 AT 命令 */
    0x00,                             /* iInterface: 描述该接口的字符串描述符的索引 */

    /* 端点2输入描述符 */
    0x07,                             /* bLength: 端点描述符的长度 */
    USB_ENDPOINT_DESCRIPTOR_TYPE,     /* bDescriptorType: Endpoint */
    0x82,                             /* bEndpointAddress: (IN2) */
    0x02,                             /* bmAttributes: 传输类型为批量传输 */
    0x20,                             /* wMaxPacketSize: 最大数据包大小 */
    0x00,
    0x00,                             /* bInterval: 传输间隔 */

    /* 端点2输出描述符 */
    0x07,                             /* bLength: 端点描述符的长度 */
    USB_ENDPOINT_DESCRIPTOR_TYPE,     /* bDescriptorType: Endpoint */
    0x02,                             /* bEndpointAddress: (OUT2) */
    0x02,                             /* bmAttributes: 传输类型为批量传输 */
    0x20,                             /* wMaxPacketSize: 最大数据包大小 */
    0x00,
    0x00,                             /* bInterval: 传输间隔 */

    /* 端点1输入描述符 */
    0x07,                             /* bLength: 端点描述符的长度 */
    USB_ENDPOINT_DESCRIPTOR_TYPE,     /* bDescriptorType: Endpoint */
    0x81,                             /* bEndpointAddress: (IN1) */
    0x03,                             /* bmAttributes: 传输类型为中断传输 */
    0x08,                             /* wMaxPacketSize: 最大数据包大小 */
    0x00,
    0x01                              /* bInterval: 传输间隔 */
};

/* USB 字符串描述符 */
const uint8_t Virtual_Com_Port_StringLangID[VIRTUAL_COM_PORT_SIZ_STRING_LANGID] =
{
    VIRTUAL_COM_PORT_SIZ_STRING_LANGID,
    USB_STRING_DESCRIPTOR_TYPE,
    0x09,
    0x04 /* LangID = 0x0409: U.S. English */
};

const uint8_t Virtual_Com_Port_StringVendor[VIRTUAL_COM_PORT_SIZ_STRING_VENDOR] =
{
    VIRTUAL_COM_PORT_SIZ_STRING_VENDOR,  /* 制造商字符串的大小 */
    USB_STRING_DESCRIPTOR_TYPE,          /* bDescriptorType*/
    /* 制造商名称: "wch.cn" */
    'w', 0, 'c', 0, 'h', 0, '.', 0, 'c', 0, 'n', 0
};

const uint8_t Virtual_Com_Port_StringProduct[VIRTUAL_COM_PORT_SIZ_STRING_PRODUCT] =
{
    VIRTUAL_COM_PORT_SIZ_STRING_PRODUCT,  /* bLength */
    USB_STRING_DESCRIPTOR_TYPE,           /* bDescriptorType */
    /* 产品名称: "USB 串口" */
    'U', 0, 'S', 0, 'B', 0, ' ', 0, 'S', 0, 'e', 0, 'r', 0, 'i', 0, 'a', 0, 'l', 0
};

uint8_t Virtual_Com_Port_StringSerial[VIRTUAL_COM_PORT_SIZ_STRING_SERIAL] =
{
    VIRTUAL_COM_PORT_SIZ_STRING_SERIAL,   /* bLength */
    USB_STRING_DESCRIPTOR_TYPE,           /* bDescriptorType */
    /* 设备序列号: "0123456789" */
    '0', 0, '1', 0, '2', 0, '3', 0, '4', 0, '5', 0 , '6', 0, '7', 0, '8', 0, '9', 0
};

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

